﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using F_SER.DAL;

namespace F_SER.ServicePorts
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码、svc 和配置文件中的类名“ServiceYJWeb”。
    /// <summary>
    /// 鄂州一卡通网站接口
    /// </summary>
    public class ServiceYJWeb : IServiceYJWeb
    {
        public string f_getval(string a_in, ref System.Data.DataSet ap_set)
        {
            string ls_ret;
            long ll_row;

            SqlConnection p_con = new SqlConnection(SqlHelper.GetSqlConnection());
            SqlCommand p_cmd = p_con.CreateCommand();

            try
            {
                p_con.Open();
                p_cmd.CommandType = CommandType.StoredProcedure;
                p_cmd.CommandText = "WP_WINFO";

                SqlParameter[] p_parm = new SqlParameter[3];
                p_parm[0] = new SqlParameter("AS_IN", SqlDbType.VarChar, 1024);
                p_parm[1] = new SqlParameter("AS_OUT", SqlDbType.VarChar, 1024);
                p_parm[2] = new SqlParameter("AI_DO", SqlDbType.Int);

                p_parm[0].Direction = ParameterDirection.Input;
                p_parm[1].Direction = ParameterDirection.Output;
                p_parm[2].Direction = ParameterDirection.Output;

                p_parm[0].Value = a_in;

                p_cmd.Parameters.Add(p_parm[0]);
                p_cmd.Parameters.Add(p_parm[1]);
                p_cmd.Parameters.Add(p_parm[2]);

                ll_row = p_cmd.ExecuteNonQuery();
                ls_ret = Convert.ToString(p_parm[1].Value);

                SqlDataAdapter p_pda = new SqlDataAdapter();
                p_pda.SelectCommand = p_cmd;

                p_pda.Fill(ap_set, "RESULT");
            }
            catch (Exception e)
            {
                ls_ret = e.ToString();
            }
            finally
            {
                p_con.Close();
                p_con.Dispose();
                p_cmd.Clone();
                p_cmd.Dispose();
            }

            return ls_ret;
        }                  
    }
}
